// Project_TU_sofia.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdlib.h>
#include <tchar.h>
#include <ctype.h>
#include <string.h>
#include <conio.h>
#include <string.h>
#include <malloc.h>

void Print(FILE *fp,char *fname);

int main()
{
FILE *tmp,*fp;
int num_words=0;
char str[81];
fopen_s(&fp,"test.txt", "rt+");
if (!fp) return NULL;
fopen_s(&tmp,"test1.txt", "wt+");
if (!tmp) return NULL;
while ( fgets(str, 80, fp) != NULL )
{
	strcpy(str, "outname.txt");
}
fclose(tmp);
fclose(fp);
Print(fp,"outname.txt");
system("PAUSE");
return 0;
}

void Print(FILE *fp,char *fname)
{
	int ch, n=0;
	char str[81];
	fopen_s(&fp,fname,"r");
	if (!fp)
	{
		return;
	}
	
	while ((ch=fgetc(fp)) != EOF)
	{
		putchar(ch);
		n++;
	}
	fclose(fp);
}